﻿using System;
using System.Collections.Generic;

namespace Pixels.Logic.GameplayEvents
{
    public class NuclearReactorExploded : GameplayEvent
    {

        Structures.NuclearReactor reactor;

        internal override void execute() {
            var tile = this.reactor.OnTile;
            var adjacent = tile.getAdjacentTiles();
            foreach (var tt in adjacent) if (tt.HasStructure) {
                tt.StructureOnTile.damage();
                foreach (var c in tt.StructureOnTile.AssignedColonists) { // 50% chance of dying
                    if (Ur.Random.QuickRnd.d100 < GlobalConsts.COLONIST_DEATH_CHANCE_ADJACENT_TO_BLAST) c.die();
                }
            }
            reactor.damage(); reactor.damage(); // make sure it explodes

            foreach (var c in reactor.AssignedColonists) c.die();

            
            

        }

        public NuclearReactorExploded(Structures.NuclearReactor reactor) { this.reactor = reactor; }

    }
}
